<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var maxArea = function(height) {
        let i = 0,j = height.length -1;
        let maxarea = null;
        while (i < j) {
            maxarea = Math.max(maxarea,(j - i)* Math.min(height[i],height[j]));
            if(height[i]< height[j]){
                i++;
            }else {
                j--;
            }
        }
        return maxarea;
    };
    console.log(maxArea([1,8,6,2,5,4,8,3,7]))
    console.log(maxArea([1,1]))
    console.log(maxArea([4,3,2,1,4]))
    console.log(maxArea([1,2,1]))
</script>
</body>
</html>